package springmvcdemo.service;

import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import springmvcdemo.mapper.MessageInfoMapper;
import springmvcdemo.model.MessageInfo;

import java.util.ArrayList;
import java.util.List;

@Service
public class MessageInfoService {
    //service调用数据层



    @Autowired
    private MessageInfoMapper messageInfoMapper;

    //调用mapper，将数据插入数据库
    public void insert(MessageInfo messageInfo) {
        messageInfoMapper.insertMessageInfo(messageInfo);
    }
    //调用数据库，查询信息
    public List<MessageInfo> selectAll() {
        return messageInfoMapper.queryAllMessageInfo();
    }
    //删除信息
    public void delete(Integer id) {
        messageInfoMapper.deleteMessageInfoById(id);
    }
    //查询某条数据是否存在
    public boolean get(Integer id) {
        MessageInfo messageInfo = messageInfoMapper.query(id);
        if(messageInfo==null) return false;
        return true;
    }

}
